home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug106 / crl.doc < prev    next >
Text File  |  1984-06-14  |  4KB  |  106 lines

  1.                 crl.doc
  2.  
  3.     Copyright (C) 1980, M J Maney
  4.  
  5.     last revised 9/6/80 21:55
  6.  
  7.  
  8.     This file shall attempt to explain the use of the macros defined in
  9.     the "crl.lib" library file.
  10.  
  11.     The purpose of the crl.lib file is to make it less painful to write
  12.     function modules in assembler that can be linked to the code
  13.     generated by the BDS C compiler. There are several reasons for
  14.     wishing to do this, the primary one being the sometimes grossly
  15.     inefficent code sequences that the compiler generates. This is not
  16.     due so much to the compiler's simple-mindedness as to the limited
  17.     capabilities of the 8080 instruction set. A clever programmer can
  18.     produce much more compact code than ANY compiler for the 8080
  19.     (or probably most any of the early microprocessors), and in some
  20.     cases the difference can be simply astounding. Thus, we shall at
  21.     times desire to replace a function originally coded in C with a
  22.     carefully optimized one written in assembler. And thus the driving
  23.     force behind the package herein described.
  24.  
  25.     There is currently one minor nuisance involved in utilizing the
  26.     macros...the hex file is NOT properly loaded by the CP/M load
  27.     utility, so good old ddt's services are required (still). But at
  28.     least all you have to do is use ddt to load the hex file. Once
  29.     the image is in memory, all that is required is to "save" the
  30.     image as a ".crl" file.
  31.  
  32.     For example, to load the functions in strfun.asm into the crl
  33.     format file (named, of course, strfun.crl), the procedure is:
  34.  
  35.     1)    assemble strfun
  36.     2)    use ddt to load the hex file produced. I've been clearing the
  37.     background to zero first, which helped during debugging of the
  38.     crl macros, but isn't really needed.
  39.     3)    note what address ddt reports, this is the top of the memory
  40.     image that must be saved.
  41.     4)    exit ddt, remembering the address
  42.     5)    save the memory image using the built-in "save" utility and
  43.     the address that you (hopefully) remembered. The number of
  44.     "pages" that must be saved are
  45.  
  46.         n = ceiling((address - base of TPA) / 0x100)
  47.  
  48.     where ceiling(x) is the smallest integer equal or larger than x.
  49.     For standard CP/M, this is simply the "100's" digit of the
  50.     address....at least for the sample files I sent.
  51.     6)    That's it
  52.  
  53.     If this sounds like a lot of work, let me reassure you...its
  54.     easier to do than to explain. I could execute the whole sequence
  55.     in far less time than its taken me to write all this, and maybe
  56.     in less time than it takes to read this (unless you're a graduate
  57.     of the Evelyn Wood system).
  58. ;                crl.lib
  59. ;
  60. ;    Copyright (C) 1980, M J Maney
  61. ;
  62. ;    First created 8/16/80
  63. ;    Last revised 8/29/80 14:00
  64. ;
  65. ;    This file contains some macro definitions designed for asembling
  66. ;    code to the "crl" format employed by the BDS C compiler and linker.
  67. ;
  68. ;
  69. ARG1    equ    3F7H
  70. ARG2    equ    ARG1+2
  71. ARG3    equ    ARG2+2
  72. ARG4    equ    ARG3+2
  73. ARG5    equ    ARG4+2
  74. ARG6    equ    ARG5+2
  75. ;
  76. ;
  77. ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
  78. ;
  79. ;                PROC
  80. ;
  81. ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
  82. ;    PROC is the function header macro. It must be used to introduce each
  83. ;    function in the source module before the object code for that module.
  84. ;    The syntax is:
  85. ;
  86. ;    PROC    func_name {,<needed functions list>}
  87. ;
  88. ;    NB: if there is more than one "needed function", then the list
  89. ;    MUST be protected by "<",">"...see MAC manual for explanation
  90. ;    of the syntax.
  91. ;
  92. ;    To maintain compatibility with the 1.32 release of C, all function
  93. ;    names must be upper-case alpha-numerics, and should also be limited
  94. ;    to a maximum of eight characters in length. The needed function list
  95. ;    must be enclosed in broken brackets if there is more than one needed
  96. ;    function.
  97. ;
  98. ;    I have modified DSTR to allow the inclusion of the underscore
  99. ;    character in function names. NB that the name in the PROC or PEND
  100. ;    statement MUST use the '?' character in place of the underscore.
  101. ;    Thus, the PROC for a function to be called '_bc' is:
  102. ;
  103. ;    PROC    ?BC
  104. ;
  105. ;
  106. ;    PROC creates the directory entry, the needed fu